<template>
	<view class="fl-s-s">
		<view class="cart-list">
			<view class="cart-list w-1 relative m-t-30">
				<view class="list-item" v-for="(item, index) in list" :key="index">
					<view class="fr-s-c w-1 m-b-20">
						<view class="fl-c h-1" style="width: 84rpx" @click="changeChooseSign(item,index)">
							<image
								:src="choose_index == index? '/static/images/shopcar/color_selected.png' : '/static/images/shopcar/noc_not_select.png'"
								style="width: 36rpx; height: 36rpx"
							></image>
						</view>
						<view class="flex-1 h-1">
							<view class="fr-s-c">
								<image :src="baseUrl.imageUrl+item.img" mode="aspectFill" style="width: 116rpx; height: 116rpx; border-radius: 12rpx"></image>
								<view class="m-l-20 flex-1 fl-b-s" style="padding: 16rpx 0">
									<text class="text-line-1 c-00 fs-30 fm-ali">{{ item.title }}</text>
									<view class="fr-b-e w-1 margin20">
										<!-- 价格 -->
										<view class="fr-s-c fm-ali" style="color: #fa360a; align-items: baseline">
											<text class="fs-24">发票金额￥</text>
											<text class="fs-36">{{ item.price }}</text>
										</view>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import config from '@/utils/base.js';
export default {
	data() {
		return {
			value: 1,
			isEdit: false,
			chooseAll: false,
			list: [],
			nodata: true,
			active_list: [],
			baseUrl: config,
			page: 1,
			last_page: '',
			choose_index:-1,
		};
	},
	onLoad() {
		this.getList();
	},
	onShow() {},
	onReachBottom() {
		if (this.page < this.last_page) {
			this.page++;
			this.getList();
		}
	},
	

	methods: {
		getList() {
			let t = this;
			t.$post({
				url: '/wanlshop/tickets/get_invoice_list',
				data:{
					sh:1
				}
			}).then((res) => {
				console.log(res);
				if (res.code == 1) {
					t.last_page = res.data.last_page;
					if (res.data.data.length > 0) {
						res.data.data.map((item) => {
							item.toggle = false;
						});
						t.list = [...res.data.data, ...t.list];
						t.nodata = !t.list.length;
					}
				}
			});
		},
		// 删除购物车数据
		delGoods() {
			uni.showModal({
				title: '提示',
				content: '确定删除选中商品吗？',
				success: (res) => {
					if (res.confirm) {
						let list = this.list;
						list = list.filter((item) => item.toggle).map((items) => (items = items.id));
						this.$get({
							url: '/mainwxapp/doPageDelGwcs',
							data: {
								gwc_ids: list.join(',')
							}
						}).then((res) => {
							this.list = this.list.filter((item) => !list.includes(item.id));
							this.nodata = !this.list.length;
							if (!this.list.length) {
								this.isEdit = false;
							}
						});
					}
				}
			});
		},
		plusNum(e) {
			console.log(e, '111');
		},
		valChange(e) {
			const { value, index } = e;
			console.log(this.list[index].num);
			this.updataGnum(index);
		},
		// 修改购物车数量
		updataGnum(index) {
			let id = this.list[index].id;
			let num = this.list[index].num;
			this.$get({
				url: '/Wxapps/doPageduogwcchange',
				data: {
					id,
					num
				}
			});
		},
		changeEdit() {
			this.isEdit = !this.isEdit;
		},
		// 单选
		changeChooseSign(item,index) {
			this.choose_index = index
			uni.$emit('fapiao',item)
			uni.navigateBack()
		},
		
	}
};
</script>

<style>
page {
	background-color: #fff;
	padding-bottom: 220rpx;
}

.cart-list {
	width: 100%;
}

>>> .u-numberbox {
	border: 2rpx solid #eeeeee !important;
	width: 130rpx !important;
	height: 42rpx !important;
	border-radius: 6rpx !important;
	font-family: Alibaba !important;
}

>>> .u-number-input {
	font-family: Alibaba;
	font-size: 22rpx;
	color: #000000;
	width: 46rpx !important;
	height: 42rpx !important;
	margin: 0 !important;
	border: none;
	border-radius: 0;
	border-left: 2rpx solid #eeeeee;
	border-right: 2rpx solid #eeeeee;
}

>>> .u-icon-minus {
	width: 42rpx !important;
	height: 42rpx !important;
	color: #c0c0c0 !important;
}

>>> .u-icon-plus {
	width: 42rpx !important;
	height: 42rpx !important;
	color: #c0c0c0 !important;
}

.common_bg {
	position: fixed;
	left: 0;
	top: 0;
	width: 100vw;
	height: 284rpx;
}

.list-item {
	width: 100%;
	/* height: 220rpx; */
	background: #ffffff;
	border-radius: 40rpx 40rpx 0 0;
	padding: 28rpx 48rpx;
	padding-left: 0;
	border-bottom: #f4f4f4 solid 2rpx;
}

.column-foot {
	width: 100%;
	height: 104rpx;
	background: #ffffff;
	border-radius: 16rpx;
}

.js-btn {
	width: 104rpx;
	height: 66rpx;
	background: linear-gradient(270deg, #e46c30 0%, #e32c1c 100%);
	/* box-shadow: 0rpx 6rpx 32rpx 2rpx rgba(250, 74, 20, 0.58); */
	border-radius: 34rpx;
	font-size: 24rpx;
	font-family: Alibaba PuHuiTi 2-55 Regular, Alibaba PuHuiTi 20;
	font-weight: normal;
	color: #ffffff;
}

.jiesuan {
	width: 100%;
	height: 184rpx;
	position: fixed;
	bottom: 0;
	left: 0;
	background-color: #fff;
	box-shadow: 0rpx -8rpx 14rpx 0rpx rgba(0, 0, 0, 0.06);
	border-bottom: 2rpx solid #f4f4f4;
}

.chat_bottom {
	font-size: 24rpx;
	font-family: Alibaba PuHuiTi 2-55 Regular, Alibaba PuHuiTi 20;
	font-weight: normal;
	color: #333333;
}

.chat_num {
	color: #e32d1d;
}

.margin20 {
	margin-top: 20rpx;
}

.list-item-top {
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.list-item-top-img {
	width: 30rpx;
	height: 30rpx;
	background-color: #ddd;
	border-radius: 50%;
	margin-right: 6rpx;
}

.text-line-1 {
	display: -webkit-box;
	word-break: break-all;
	text-overflow: ellipsis;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 1;
	overflow: hidden;
}
.choose_img {
	width: 300rpx;
	height: 90rpx;
	border-radius: 20rpx;
	background: linear-gradient(180deg, #4ecc81 0%, #34b806 100%);
	color: #fff;
	line-height: 90rpx;
	text-align: center;
	margin: 0 auto;
}
.choose_img_text {
	width: 100%;
	text-align: center;
	font-size: 32rpx;
	font-family: Alibaba PuHuiTi 2-65 Medium, Alibaba PuHuiTi 20;
	font-weight: normal;
	color: #333333;
	margin-top: 30rpx;
}
.shangjia-bottom {
	font-size: 22rpx;
	font-family: Alibaba PuHuiTi 2-65 Medium, Alibaba PuHuiTi 20;
	font-weight: normal;
	color: #e56d31;
	padding: 0 10rpx;
	margin-top: 20rpx;
	padding-left: 70rpx;
}
</style>
